﻿using System;
using System.Collections.Generic;
using RestSharp;
using Ymatou.API.Common;
using Ymatou.Evaluate.Seller.Model.ApiModel.Response.Query;
using Ymatou.ServiceCenter;

namespace Ymatou.Evaluate.Seller.Model.ApiModel.Request.Query
{
    [Resource("evaluate.iapi.ymatou.com", "api/query/GetEvaluateList", Method.GET, ParameterBuildType.Json)]
    public class GetEvaluateListRequest : BaseRequestModel<GetEvaluateListResponse>
    {
        public override string ApiName { get { return "api/query/GetEvaluateList"; } }
        public override bool HttpGet { get { return true; } }

        /// <summary>
        /// 买手Id
        /// </summary>
        public int SellerId { get; set; }

        /// <summary>
        /// 商品Id
        /// </summary>
        public string ProductId { get; set; }

        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime? BeginTime { get; set; }

        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime? EndTime { get; set; }

        /// <summary>
        /// 每页显示条数
        /// </summary>
        public int PageSize { get; set; }

        /// <summary>
        /// 页码
        /// </summary>
        public int PageIndex { get; set; }

        /// <summary>
        /// 分值列表
        /// </summary>
        public List<decimal> ScoreList { get; set; }

        /// <summary>
        /// 是否删除
        /// </summary>
        public bool IsDeleted { get; set; }

        public override void Validate()
        {
            const string errCode = "-1";
            if (SellerId <= 0)
            {
                throw new BussniessException(errCode, "非法买手Id");
            }
            if (BeginTime == null)
            {
                throw new BussniessException(errCode, "开始时间不能为空");
            }
            if (EndTime == null)
            {
                throw new BussniessException(errCode, "结束时间不能为空");
            }
            var ts = EndTime.Value.Subtract(BeginTime.Value);
            if (ts.Days > 60)
            {
                throw new BussniessException(errCode, "查询时间跨度不能超过60天");
            }


            base.Validate();
        }
    }
}
